home *** CD-ROM | disk | FTP | other *** search
- /* set handlers and other parts for translit */
-
-
- makset(array,k,set,size)
- int k,size;
- char set[],array[];
- {
- int j;
-
- j = 0;
- filset(EOS,array,k,set,&j,size);
- return(addset(EOS,set,&j,size));
- }
-
- addset(c,set,j,maxsize)
- int *j,maxsize;
- char c,set[];
- {
- if(*j >maxsize)
- return(NO);
- else {
- set[*j] = c;
- (*j)++;
- return(YES);
- }
- }
-
- #define DASH '-'
- #define ESCAPE '\\'
-
- /* expand set at array[i] into set[j], stop at delim */
- filset(delim,array,i,set,j,maxset)
- int i,*j,maxset;
- char array[],set[];
- char delim;
- {
- char esc();
- static char digits[] ={ "0123456789" };
- static char lowalf[] ={ "abcdefghijklmnopqrstuvwxyz" };
- static char upalf[] ={ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" };
-
-
- for (;array[i] != delim && array[i] != EOS; ++i)
- if(array[i] == ESCAPE)
- addset(esc(array,&i),set,j,maxset);
- else if (array[i] != DASH)
- addset(array[i],set,j,maxset);
- else if ((*j) <=0 || array[i+1] == EOS) /*literal - */
- addset(DASH,set,j,maxset);
- else if (index(digits,set[(*j)-1])>-1)
- dodash(digits,array,&i,set,j,maxset);
- else if (index(lowalf,set[(*j)-1])>-1)
- dodash(lowalf,array,&i,set,j,maxset);
- else if (index(upalf,set[*j-1])>-1)
- dodash(upalf,array,&i,set,j,maxset);
- else
- addset(DASH,set,j,maxset);
- }
-
-
- /* expand array [i-1]-array[i+1] into set[j]..from valid */
- dodash(valid,array,i,set,j,maxset)
- int *i,*j,maxset;
- char array[],set[],valid[];
- {
- int k,limit,index(),addset();
- char esc();
-
- (*i)++;
- (*j)--;
- limit = index(valid,esc(array,i));
- for( k = index(valid,set[*j]) ; k <= limit ; k++)
- addset(valid[k],set,j,maxset);
- }
-